第 7步:我们已经准备好编写我们的get_user_input函数了!让我们向用户询问一些星星。

input()将用户的输入作为string返回。要将输入用作数字,我们需要将其转换为integer

  • , 拖动Input an Integerget_user_input()中缩进。
  • 更改"How old are you?""How many stars should there be?" .
  • 然后,将=符号左侧的变量从my_varnumber

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)